﻿@model ViewModelResult
@{

    var _t = Model.Topic;

    var _topics = (List<Topic>)Model.List;
    var _likes = (List<Like>)Model.OtherList;
}
@if (Model.ButtonPageRenderPosition == ButtonPageRenderPosition.Both || Model.ButtonPageRenderPosition == ButtonPageRenderPosition.Top)
{
    @Html.Partial("_ButtonPageRender", Model)
}
<div class="site-block dd-popup-menu" id="thread_options">
    <ul class="dd-menu">
        <li>
            @Html.Link(string.Format("{0}?TopicId={1}", ForumContext.GetAbsoluteUrl(ForumUrls.SUBCRIBE), _t.TopicId), ForumContext.GetText(LanguageSection.TOPICS, "Subcribe"))
        </li>
        <li>
            @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_FORUM, _t.ForumId), ForumContext.GetText(LanguageSection.TOPICS, "GO_FORUM"))
        </li>
        <li>
            @Html.Link(string.Format("{0}?TopicId={1}", ForumContext.GetAbsoluteUrl(ForumUrls.SEND_EMAIL), _t.TopicId), ForumContext.GetText(LanguageSection.TOPICS, "send_email"))
        </li>
        <li>
            @Html.Link("javascript:window.print()", ForumContext.GetText(LanguageSection.TOPICS, "PRINT_THIS_TOPIC"))
        </li>
    </ul>
</div>
<div class="site-block dd-popup-menu" id="link_back_popup">
    <ul class="dd-menu">
        <li>
            @Html.Link(ForumContext.ThreadLink(_t.TopicId, _t.TopicName), ForumContext.GetText(LanguageSection.TOPICS, "link_back_url"), new { @onclick = string.Format("$.MvcForum.prompt('{0}',this.href);return false;", ForumContext.GetText(LanguageSection.TOPICS, "link_back_prompt")) })
        </li>
    </ul>
</div>
<div class="site-block white-t">
    <ul class="toolbar">
        <li class="dropdown {dropdown:{target:'#link_back_popup'}}"><span>
            @ForumContext.GetText(LanguageSection.TOPICS, "link_back")
        </span></li>
        <li class="dropdown {dropdown:{target:'#thread_options'}}"><span>
            @ForumContext.GetText(LanguageSection.TOPICS, "OPTIONS")
        </span></li>
    </ul>
    <br class="empty" />
</div>

@if (_topics != null)
{
    foreach (var p in _topics)
    {
        var _like = _likes != null ? _likes.FindAll(x => x.TopicId == p.TopicId) : null;

        var model = new ViewModelResult
                        {
                            IsMod = Model.IsMod,
                            Topic = p,
                            OtherList = _like
                        };
    @Html.Partial("_Post", model)
    
    }
}
@if (!string.IsNullOrWhiteSpace(_t.Tags))
{
    @Html.Partial("_Tags", _t.Tags.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries))    
}
@if (Model.IsMod)
{
    @Html.Partial("_ModeratorTools",Model.Forum)
    @*@Html.Action("ModeratorTools")*@
}
@if (Model.ButtonPageRenderPosition == ButtonPageRenderPosition.Both || Model.ButtonPageRenderPosition == ButtonPageRenderPosition.Bottom)
{
    @Html.Partial("_ButtonPageRender", Model)
}
<div class="site-block white-t">
    <div class="site-block-content p-8 center">
        @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_POST, _t.TopicId) + "?do=prev", ForumContext.GetText(LanguageSection.TOPICS, "PREV_THREAD"), new { @class = "prev-thread icon-16 prev" })
        | @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_POST, _t.TopicId) + "?do=next", ForumContext.GetText(LanguageSection.TOPICS, "NEXT_THREAD"), new { @class = "next-thread icon-16 next" })
    </div>
</div>
@if (ForumContext.Configuration.AllowQuickReply && ForumContext.AllowAccess(CommandType.Reply, null, _t))
{
    @Html.Partial("_QuickPost", _t)
}
